#include "ThreadExecutor.hpp"

#include <iostream>

ThreadExecutor::ThreadExecutor() : wk_(io_context_)
{

    std::cout<<"ThreadExecutor construct"<<std::endl;

    std::unique_ptr<std::thread> myPtr(new std::thread([this](){io_context_.run();}));
    thread_ = std::move(myPtr);
    thread_->detach();
}

ThreadExecutor::~ThreadExecutor()
{
    io_context_.stop();
    std::cout<<"ThreadExecutor destruct"<<std::endl;
}